function [ PercentageRatio, ClassificationOutput ] = SvmOneToAll(DataSet, Gamma)

[Samples, Labels, Classes] = LoadTrainData(DataSet);

samplesSize = size(Samples);
SamplesCount = samplesSize(2);

ClassVectors = zeros(Classes, SamplesCount);

for i = 1:1:Classes,
    for j = 1:1:SamplesCount,
        ClassVectors(i, j) = (Labels(j) == i);
    end
end

AlphaY = cell(1, Classes);
SVs = cell(1, Classes);
Bias = cell(1, Classes);
Parameters = cell(1, Classes);
nSV = cell(1, Classes);
nLabel = cell(1, Classes);

for i = 1:1:Classes,
    [AlphaY{i}, SVs{i}, Bias{i}, Parameters{i}, nSV{i}, nLabel{i}] = RbfSVC(Samples, ClassVectors(i, :), Gamma);
end

[Samples, Labels] = LoadTestData(DataSet);

ClassRate = cell(1, Classes);
DecisionValue = cell(1, Classes);
Ns = cell(1, Classes);
ConfMatrix = cell(1, Classes);
PreLabels = cell(1, Classes);

samplesSize = size(Samples);
SamplesCount = samplesSize(2);

ClassVectors = zeros(Classes, SamplesCount);

for i = 1:1:Classes,
    for j = 1:1:SamplesCount,
        ClassVectors(i, j) = (Labels(j) == i);
    end
end

for i = 1:1:Classes,
    [ClassRate{i}, DecisionValue{i}, Ns{i}, ConfMatrix{i}, PreLabels{i}] = SVMTest(Samples, ClassVectors(i, :), AlphaY{i}, SVs{i}, Bias{i}, Parameters{i}, nSV{i}, nLabel{i});
end

ClassificationOutput = zeros(1, SamplesCount);

for j = 1:1:SamplesCount
    HitCount = 0;
    ClassificationLabel = 0;
    for i = 1:1:Classes
        if (PreLabels{i}(j) > 0)
            HitCount = HitCount + PreLabels{i}(j);
            ClassificationLabel = i;
        end
    end
    
    if (HitCount == 1)
        ClassificationOutput(j) = ClassificationLabel;
    end
end

TotalHitCount = 0;

for j = 1:1:SamplesCount
    if (ClassificationOutput(j) == Labels(j))
        TotalHitCount = TotalHitCount + 1;
    end
end

PercentageRatio = (TotalHitCount/SamplesCount)*100;

end
